<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let company = {
        sales: [
          { name: 'John', salary: 1000 },
          { name: 'Alice', salary: 1600 },
        ],
        development: {
          sites: [
            {
              name: 'Peter',
              salary: 2000,
            },
            {
              name: 'Alex',
              salary: 1800,
            },
          ],
          internals: [
            {
              name: 'Jack',
              salary: 1300,
            },
          ],
        },
        teacher: {
          h5: [
            { name: 'lili', salary: 2000 },
            { name: 'lucy', salary: 2000 },
          ],
          java: [
            { name: 'tom', salary: 2000 },
            { name: 'alix', salary: 2000 },
          ],
        },
      };

      function tree(data) {
        for (let k in data) {
          if (Array.isArray(data[k])) {
            data[k].forEach((el) => {
              console.log(el.name);
            });
          } else {
            for (let j in data[k]) {
              if (Array.isArray(data[k][j])) {
                data[k][j].forEach((el) => {
                  console.log(el.name);
                });
              }else{
                
              }
            }
          }
        }
      }

      tree(company);
    </script>
  </body>
</html>
